home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group02b.txt
/
000086_icon-group-sender_Wed Oct 23 16:27:29 2002.msg
< prev
next >
Wrap
Internet Message Format
|
2003-01-02
|
1KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9NNR0g29135
for icon-group-addresses; Wed, 23 Oct 2002 16:27:01 -0700 (MST)
Message-Id: <200210232327.g9NNR0g29135@baskerville.CS.Arizona.EDU>
From: "Paul W. Abrahams" <abrahams@acm.org>
To: icon-group@cs.arizona.edu
Subject: move_corresponding: the procedure
Date: Wed, 23 Oct 2002 16:32:23 -0400
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Here's the code of the move_corresponding procedure I referred to earlier
(which, according to Clint, will work only in newer versions of Icon). It
might be a useful addition to the Icon library.
Paul
-----------------------
procedure move_corresponding(s1,s2)
# move_corresponding moves correspondingly-named fields from the
# record parameter s1 to the record parameter s2. Fields whose
# names are not common are not affected. The ordering of the field
# names is irrelevant.
local names1,names2,n,i
# Generate the set of common names
names1:=set()
every i := 1 to *s1 do
insert(names1,name(s1[i]) ? (tab(upto('.')),=".",tab(0)))
every write(!names1)
names2:=set()
every i := 1 to *s2 do
insert(names2,name(s2[i]) ? (tab(upto('.')),=".",tab(0)))
# Now copy the components with shared names
every n := !(names1**names2) do
s1[n] := s2[n]
end